<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/toOneList' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据中心</el-breadcrumb-item>
      <el-breadcrumb-item>客户管理管理</el-breadcrumb-item>
      <el-breadcrumb-item>客户信息编辑</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">

      <!--添加客户-->
        <el-form :model="form" label-width="70px" >
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="编号">
                <el-input v-model="form.code"  size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="描述">
                <el-input v-model="form.remarks"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="客户名称">
                <el-input v-model="form.name"  size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="首次合作时间">
                <el-date-picker placeholder="选择日期" style="width: 100%;" type="date"
                                v-model="form.cooperDate"  size="small"> </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="发票类型">
                <el-input v-model="form.invoiceType"  size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="发票抬头">
                <el-input v-model="form.invoiceTitle"  size="small"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="税号">
                <el-input v-model="form.invoiceNum"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="税率">
                <el-input v-model="form.taxRate"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="22">
            <el-col :span="11">
              <el-form-item label="公司地址">
                <el-input v-model="form.address"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item label="所属行业">
                <el-input v-model="form.industry"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
      <el-button @click="saveCustomer()" plain type="info">确定</el-button>
      <el-button @click="reset()" type="primary">重置</el-button>
      <el-button @click="tolist()">返回</el-button>
    </el-card>
</div>
</template>

<script>
    export default {
        name: "CustomerUpdate",
      data(){
          return{
            form:{},
            id:null,
          }
      },
      methods:{
        tolist(){
          this.$router.push('/Customer');
        },
        get:function(){
          this.$http.get("/customer/get/"+this.id).then((res) => {
            if (res.data.success) {
              this.form = res.data.result //赋值
            } else {
              this.$message.error(res.data.message);
            }
          });
        },
        saveCustomer:function () {
          this.$http.post("/customer/save", this.form).then((res) => {
            //如何提示
            if (res.data.success) {
              this.$message({
                message: res.data.message,
                type: 'success'
              });
            } else {
              this.$message.error(res.data.message);
            }
          });
        }
      },
      mounted(){
        this.id=this.$route.query.id;//$route
          this.get();
      }
    }
</script>

<style scoped>

</style>
